"use strict";
exports.__esModule = true;
var formatTime = function (date) {
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var hour = date.getHours();
    var minute = date.getMinutes();
    var second = date.getSeconds();
    return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':');
};
exports.formatTime = formatTime;
var formatNumber = function (n) {
    n = n.toString();
    return n[1] ? n : '0' + n;
};
var ORDERTYPE;
(function (ORDERTYPE) {
    ORDERTYPE[ORDERTYPE["WAIT_PAY"] = 1] = "WAIT_PAY";
    ORDERTYPE[ORDERTYPE["WAIT_GROUP"] = 2] = "WAIT_GROUP";
    ORDERTYPE[ORDERTYPE["WAIT_SELLER_SEND_GOODS"] = 3] = "WAIT_SELLER_SEND_GOODS";
    ORDERTYPE[ORDERTYPE["WAIT_BUYER_CONFIRM_GOODS"] = 4] = "WAIT_BUYER_CONFIRM_GOODS";
    ORDERTYPE[ORDERTYPE["TRADE_SUCCESS"] = 5] = "TRADE_SUCCESS";
    ORDERTYPE[ORDERTYPE["CLOSED"] = 6] = "CLOSED";
    ORDERTYPE[ORDERTYPE["ABNORMAL"] = 7] = "ABNORMAL";
    ORDERTYPE[ORDERTYPE["IS_PREORDER"] = 8] = "IS_PREORDER";
})(ORDERTYPE || (ORDERTYPE = {}));
exports.ORDERTYPE = ORDERTYPE;
;
/**
        * 获取上一个月
        *
        * @date 格式为yyyy-mm-dd的日期，如：2014-01-25
        */
function getPreMonth(date) {
    var arr = date.split('/');
    var year = arr[0]; //获取当前日期的年份
    var month = arr[1]; //获取当前日期的月份
    var day = arr[2]; //获取当前日期的日
    var days = new Date(year, month, 0);
    //days = days.getDate(); //获取当前日期中月的天数
    var year2 = year;
    var month2 = parseInt(month) - 1;
    if (month2 == 0) {
        year2 = parseInt(year2) - 1;
        month2 = 12;
    }
    var day2 = day;
    var days2 = new Date(year2, month2, 0);
    var days2_new = days2.getDate();
    if (day2 > days2_new) {
        day2 = days2_new;
    }
    // if (month2 < 10) {
    //     month2 = '0' + month2;
    // }
    var t2 = year2 + '-' + month2 + '-' + day2;
    return t2;
}
exports.getPreMonth = getPreMonth;
